//
//  ViewController.swift
//  SwiftTestDemo
//
//  Created by John on 2018/5/16.
//  Copyright © 2018年 company. All rights reserved.
//

import UIKit

indirect enum ArithmeticExpression {
    case number(Int)
    case addition(ArithmeticExpression,ArithmeticExpression)
    case multiplication(ArithmeticExpression,ArithmeticExpression)
}

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let five = ArithmeticExpression.number(5)
        let four = ArithmeticExpression.number(4)
        let sum = ArithmeticExpression.addition(five, four)
        let product = ArithmeticExpression.multiplication(sum, ArithmeticExpression.number(2))
        
        print(evaluate(product))
    }
    
    let product = ArithmeticExpression.multiplication(ArithmeticExpression.addition(ArithmeticExpression.number(5), ArithmeticExpression.number(4)), ArithmeticExpression.number(2))
    
    func evaluate(_ expression:ArithmeticExpression) -> Int {
        switch expression {
        case let .number(value):
            return value
        case let .addition(left, right):
            return evaluate(left) + evaluate(right)
        case let .multiplication(left, right):
            return evaluate(left) * evaluate(right)
        }
    }

    struct Resolution {
        var width = 0
        var height = 0
        
    }
    
    class VideoModel {
        var resolution = Resolution(width:10,height:20)
        var interlaced = false
        var frameRate = 0.0
        var name : String?
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

